package com.hellogood.yaohuo.server.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;

import com.hellogood.yaohuo.server.db.DBHelper;
import com.hellogood.yaohuo.shared.entity.PsThDetail;

public class PsThDetailDAO extends DBHelper {
	Logger log = Logger.getLogger(this.getClass());
	@Override
	public List<?> initializeObject(ResultSet rs) throws SQLException {
		List<PsThDetail> thDetailList = new ArrayList<PsThDetail>();
		if (rs != null) {
			while (rs.next()) {
				PsThDetail thDetail = new PsThDetail();
				thDetail.setPsThBillNo(rs.getString("psThBillNo"));
				thDetail.setPluCode(rs.getString("pluCode"));
				thDetail.setBarCode(rs.getString("barCode"));
				thDetail.setDepCode(rs.getString("depCode"));
				thDetail.setDepName(rs.getString("depName"));
				thDetail.setPluName(rs.getString("pluName"));
				thDetail.setBra(rs.getString("bra"));
				thDetail.setColor(rs.getString("color"));
				thDetail.setSize(rs.getString("CSize"));
				thDetail.setjPrice(rs.getBigDecimal("jPrice"));
				thDetail.setNetJPrice(rs.getBigDecimal("netJPrice"));
				thDetail.setPrice(rs.getBigDecimal("price"));
				thDetail.setCounts(rs.getInt("counts"));
				thDetail.setCost(rs.getBigDecimal("cost"));
				thDetail.setNetCost(rs.getBigDecimal("netCost"));
				thDetail.setTotal(rs.getBigDecimal("total"));
				thDetail.setTimeMark(rs.getString("timeMark"));
				thDetail.setRzDate(rs.getString("rzDate"));
				thDetail.setRemark(rs.getString("remark"));
				thDetailList.add(thDetail);
			}
		}
		return thDetailList;
	}

	@SuppressWarnings("unchecked")
	public List<PsThDetail> getDetailByBillNo(String billNo) {
		List<PsThDetail> list = new ArrayList<PsThDetail>();
		String sql = "SELECT * FROM psThDetail WHERE psThBillNo = '" + billNo + "'";
		list = (List<PsThDetail>) super.query(sql);
		return list;
	}
}
